package com.demo.common.utils;

import org.springframework.stereotype.Component;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

import javax.annotation.Resource;

/**
 * @author wangning
 * @date 2023/12/6 15:08
 */
@Component
public class JedisUtils {

    @Resource
    private JedisPool jedisPool;

    /*获取Jedis资源*/
    public Jedis getJedis() {
        return jedisPool.getResource();
    }

    /*释放Jedis连接*/
    public void close(Jedis jedis) {
        if (jedis != null) {
            jedis.close();
        }
    }
}
